package com.neu.his.commonutils.exceptionhandler;


import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import com.neu.his.commonutils.R;

/**
 * 统一异常处理类
 */
@ControllerAdvice
public class GlobalExceptionHandler {
    //指定异常
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public R error(Exception e){
        e.printStackTrace();
        return R.error().message("执行全局异常处理");
    }
    //自定义异常处理 HisException
    @ExceptionHandler(HisException.class)
    @ResponseBody
    public R error(HisException e){    
        e.printStackTrace();
        return R.error().code(e.getCode()).message(e.getMsg());
    }


}
